package cate.game.role.res.worldtree.msg;

import cate.common.annotation.FuncOpenJudge;
import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDFunc;
import cate.common.table.d.GDOperation;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBWorldTree;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "清cd 英雄  共享の 请求")
@OperationSetter(value = GDOperation.WORLD_TREE_CLEAR_CD, sub = "pos")
@FuncOpenJudge(GDFunc.WORLD_TREE)
public class HeroShareCleanCDReq implements MsgInput {
    @NoteField(value = "清理方式", detail = "1 2")
    public int type;

    @NoteField(value = "位置", detail = "位置")
    public int pos;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        int cleanType = type == 2 ? 2 : 1;
        GameResult<Void> rr = cc.getRole().getRes().worldTree.heroShare.cleanBoxCD(cleanType, pos);
        if (rr.ok()) {
            cc.sendNow(new HeroShareCleanCDResp(pos));
            cc.sendNow(new HeroShareDataResp(cc.getRole().getRes().worldTree.heroShare));
        } else {
            game.notice.message(cc.getRole(), rr.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBWorldTree.CLEAR_CD_REQ;
    }
}
